<?php
namespace app\wechat\controller\admin;
use app\common\annotation\NodeAnnotation;

use app\common\controller\Admin;
use think\Request;

/**
 * @NodeAnnotation(
 *     title="设置管理",
 *     parent="wechat/admin.index",
 *     is_menu=0,
 *     is_view=0,
 *     auth=1,
 * )
 */
class Config extends Admin
{
    /**
     * @NodeAnnotation(
     *     title="配置管理",
     *     parent="wechat/admin.config",
     *     MenuRoot="wechat/admin.index"
     * )
     */

    public function index(Request $request)
    {
        $officialSetting = get_option('wechat_official');
        $this->assign([
            "official" => $officialSetting
        ]);
        return $this->fetch();
    }

    /**
     * @NodeAnnotation(
     *     title="配置资源保存",
     *     parent="wechat/admin.config",
     *     is_menu=0,
     *     is_view=0,
     *     MenuRoot="wechat/admin.index"
     * )
     */
    public function save(Request $request)
    {
        $post = $request->post();
        set_option('wechat_official', $post);
        $this->success("保存成功！");
    }

}